package com.example.controller.user;

import com.example.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("userShopController")
@Slf4j
@Tag(name = "店铺接口")
@RequestMapping("/user/shop")
public class ShopController {
    public static final String KEY="SHOP_STATUS";


    @Autowired
    private RedisTemplate redisTemplate;


    /**
     * 用户端显示营业状态 查询操作
     */
    @GetMapping("/status")
    @Operation(summary = "用户端显示营业状态")
    public Result getShop(){
        Integer shopStatus = (Integer) redisTemplate.opsForValue().get(KEY);
        log.info("用户端获取店铺状态:{}",shopStatus==1?"营业中":"打烊中");
        return Result.success(shopStatus);
    }
}
